#include <vector>
#include <unordered_map>

using std::vector;
using std::unordered_map;
using std::pair;

class Solution {
public:
    int singleNumber(vector<int>& nums) {
        int ret = 0;
        for (int i = 0; i < 32; i++) {
            int total = 0;
            for (int k : nums) {
                total += ((k >> i) & 1);
            }
            if (total % 3 > 0) {
                ret |= (1 << i);
            }
        }
        return ret;
    }
};